function multiSelectDelete(optionId, fieldId){
    var url = "./select.php?action=multiSelectDelete";
    var post = new Object;
    post["optionId"] = optionId;
    post["fieldId"] = fieldId;
    $.post(url,post,function(response){
        if(response == 1) $('ul#multiselectList-'+fieldId+' li#option-'+optionId).remove();
    });
}

function multiSelectClear(fieldId){
    var url = "./select.php?action=multiSelectClear";
    var post = new Object;
    post["itemId"] = itemId;
    post["fieldId"] = fieldId;
    if (confirm("Czy napewno usun\u0105\u0107 wzystkie powi\u0105zania?")){
        $.post(url,post,function(response){
            if(response == 1)  $('ul#multiselectList-'+fieldId).html(null);
        });
    }
    
}

function multiSelectAdd(fieldId){
    var post = new Object;
    var url;
    post['fieldId'] = fieldId;
    var options = new Array;
    $('select#multiselect-'+fieldId+' :selected').each(function(i, selected){
        options[i] = $(selected).val();
    });
    post["options"] = options;
       if($("input#itemId").val() == ""){
        createNewItem();
    }
    post["itemId"] = $("input#itemId").val();
    url = "./select.php?action=multiSelectAdd";
    post['fieldId'] = fieldId;
    $.post(url,post,function(response){
        $('ul#multiselectList-'+fieldId).html(response);
    });    
}